package com.myidis.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myidis.entity.QuotaProvider;
import com.myidis.servlet.QuotaProviderServlet;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/provider")
@Api(tags = "指标提供方管理接口")
public class QuotaProviderController {

	@Autowired
	private QuotaProviderServlet providerServlet;

	@ResponseBody
	@RequestMapping("/list")
	@ApiOperation("获取所有指标提供方的信息")
	public List<QuotaProvider> list() {
		return providerServlet.all();
	}

	@ResponseBody
	@RequestMapping("/entity")
	@ApiOperation("获取一个指标提供方的信息")
	public QuotaProvider one(@RequestBody QuotaProvider provider) {
		return providerServlet.getOne(provider.getId());
	}

	@ResponseBody
	@RequestMapping("/add")
	@ApiOperation("添加一个指标提供方的信息")
	public int add(@RequestBody QuotaProvider provider) {
		return providerServlet.insert(provider);
	}
	
	@ResponseBody
	@RequestMapping("/addAll")
	@ApiOperation("添加一组指标提供方的信息")
	public int addAll(@RequestBody List<QuotaProvider> providers) {
		return providerServlet.insertAll(providers);
	}
	
	@ResponseBody
	@RequestMapping("/upd")
	@ApiOperation("修改一个指标提供方的信息")
	public int upd(@RequestBody QuotaProvider provider) {
		return providerServlet.update(provider);
	}

	@ResponseBody
	@RequestMapping("/del")
	@ApiOperation("删除一个指标提供方的信息")
	public int del(@RequestBody int id) {
		return providerServlet.delete(id);
	}
	
	@ResponseBody
	@RequestMapping("/delAll")
	@ApiOperation("删除一组指标提供方的信息")
	public int delAll(@RequestBody int[] ids) {
		return providerServlet.deleteAll(ids);
	}
}
